package com.yanq.liancar.adapter;

import android.support.annotation.Nullable;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.yanq.liancar.R;
import com.yanq.liancar.bean.OrderListBean;
import com.yanq.liancar.bean.SelectUserAllOrdersBean;

import java.util.List;

public class ShopOrderListAdapter extends BaseQuickAdapter<SelectUserAllOrdersBean.DataBean.ListBean, BaseViewHolder> {
    public ShopOrderListAdapter(int layoutResId, @Nullable List<SelectUserAllOrdersBean.DataBean.ListBean> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, SelectUserAllOrdersBean.DataBean.ListBean item) {
        helper.setText(R.id.tv_title, item.getOrder_goods_name())
                .setText(R.id.tv_content, item.getOrder_goods_introduction())
                .setText(R.id.tv_price, "¥" + item.getOrder_goods_price())
                .setText(R.id.tv_num, "X" + item.getOrder_goods_num())
                .addOnClickListener(R.id.tv_evaluate);


        ImageView imageView = helper.getView(R.id.item_img);
        RequestOptions options=new RequestOptions();
        options.placeholder(R.mipmap.item_img);
        Glide.with(mContext).load(item.getOrder_goods_photo()).apply(options).into(imageView);


        if (item.getOrder_status() == 1) {
            helper.setText(R.id.tv_state, "待支付");
            helper.setText(R.id.tv_evaluate, "支付");
        } else if (item.getOrder_status() == 2) {
            helper.setText(R.id.tv_state, "待发货");
            helper.setText(R.id.tv_evaluate, "待发货");
        } else if (item.getOrder_status() == 3) {
            helper.setText(R.id.tv_state, "待收货");
            helper.setText(R.id.tv_evaluate, "确认收货");
        }else if (item.getOrder_status() == 4) {
            helper.setText(R.id.tv_state, "待评价");
            helper.setText(R.id.tv_evaluate, "去评价");
        }else {
            helper.setText(R.id.tv_state, "已完成");
            helper.setText(R.id.tv_evaluate, "完成");
        }


    }

}
